package com.dragon.pear.modules.sample.service.assistants.converters;

import java.sql.Timestamp;
import com.dragon.common.base.utils.ConvertUtil;
import com.dragon.common.base.utils.DbUtil;
import com.dragon.common.spring.annotations.DataConverter;
import com.dragon.common.spring.business.base.BaseConverter;
import com.dragon.utils.TimeUtil;
import com.dragon.pear.modules.sample.domain.entity.SmpOrderEntity;
import com.dragon.pear.modules.sample.web.model.params.create.SmpOrderCreateParam;
import com.dragon.pear.modules.sample.web.model.params.update.SmpOrderUpdateParam;
import com.dragon.pear.modules.sample.web.model.results.SmpOrderResult;

/**
 * @author Chris Chan
 * Create on 2025-10-15 17:59
 * Use for: 订单 业务数据转换助手
 * Explain:
 * 
 */
@DataConverter
public class SmpOrderConverter implements BaseConverter<
        SmpOrderEntity,
        SmpOrderCreateParam,
        SmpOrderUpdateParam,
        SmpOrderResult> {
    @Override
    public SmpOrderEntity fromParam(SmpOrderCreateParam param) {
        SmpOrderEntity entity = new SmpOrderEntity();
        ConvertUtil.copyProperties(param, entity, "id");
        // 生成编码
        entity.setCode(DbUtil.buildCode());
        return entity;
    }

    @Override
    public SmpOrderEntity fromUpdateParam(SmpOrderUpdateParam param) {
        SmpOrderEntity entity = ConvertUtil.convert(param, SmpOrderEntity.class);
        return entity;
    }

    @Override
    public SmpOrderResult toResult(SmpOrderEntity entity) {
        SmpOrderResult result = ConvertUtil.convert(entity,SmpOrderResult.class);
        return result;
    }
}